package day17_Inet.demo03_UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receive_UDP {
    public static void main(String[] args) throws Exception{
        DatagramSocket ds = new DatagramSocket(9999);
        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length);
        for (int i =1; i <=4; i++) {
            ds.receive(dp);
            System.out.println(new String(dp.getData(),0,dp.getData().length));
            System.out.println(dp.getLength());
            System.out.println("接收的数据为"+i);
        }
        ds.close();
    }
}
